<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.sinodata.bsm.center.purview.FunctionConstants"%>
<%@page import="com.sinodata.bsm.center.purview.UserFunctionValidate"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <title>event-correlation-common</title>
	<%@ include file="../include/common.jsp"%>
	<%@ include file="../include/jbox.jsp"%>
	<%@ include file="../include/table.jsp"%>
	<script type="text/javascript">
	function datagrid(){
		var oTable=	$('#depmtList').dataTable();
		oTable.fnPageChange("first",true);
	}
	$(function(){
		$("#name").keyup(function(event){  
            if(event.keyCode == 13){  
                search();
            }  
       	});  
		
		//加载grid
		var oTable=	$('#depmtList').dataTable({
			"bProcessing": true, 
			"bServerSide": true,
			"sServerMethod": 'POST',
			"sAjaxSource":'${pageContext.request.contextPath}/event/event-correlation!list.action?',
			"bPaginate": true,
			"bSort": true,
			"bFilter":false,
			"bJQueryUI":false,
			"sPaginationType": "full_numbers",
			"sDom":'rt <"bottom"flpi>',
			"aLengthMenu": [[10, 20, 50, 100], [10, 20, 50,100]],
			"aoColumns":[
				<%if(UserFunctionValidate.sysFunctionValidate(FunctionConstants.SYSTEM_MANAGER)){%>
					{"mDataProp":"op","":"center","bSortable": false},
				<%}%>	
				{"mDataProp":"name","bSortable": false},
				{"mDataProp":"mainEventTypeName","bSortable": false},
				{"mDataProp":"status","bSortable": false},
				{"mDataProp":"memo","bSortable": false},
				{"mDataProp":"id","bVisible":false}
			], 
			 "oLanguage": { 
			 				"sLengthMenu": "每页 _MENU_ 条",
			 		 		"sZeroRecords": "  ",
							"sInfo": "当前从 _START_ 到 _END_ 条,共 _TOTAL_ 条记录", 
							"sInfoEmpty": "没有找到记录",
							"oPaginate":{"sFirst":"首页","sPrevious":"上一页","sNext":"下一页","sLast":"尾页"}	
			},
		    "fnServerParams":function(aoData){
		    	var name = $('#name').val();
		    	if(name!='')
		    	{
		    		aoData.push({'name':'name','value':name});
		    	}
		    }
		});
	});
	function search(){
		var oTable=	$('#depmtList').dataTable();
		oTable.fnPageChange("first",true);
	}
	function add(){
		window.location.href="${pageContext.request.contextPath}/event/event-correlation!add.action";
	}
	function del(id){
		var submit = function (v, h, f) {
		    if (v == 'ok') {
		    	$.ajax({
		    		type : "POST",
		    		url : "${pageContext.request.contextPath}/event/event-correlation!delete.action", //请求的action
		    		data : {id:id}, //传的参数
		    		dataType : 'json',
		    		success : function(data) { //结果
		    			if(data == true){
		    				window.setTimeout(function () { $.jBox.tip('删除成功。', 'success'); }, 100);
							datagrid();
		    			}else{
		    				getTopWin(window).getMessageBox().alert("此规则已经被删除了","提示");
		    				datagrid();
		    			}
		    		}
		    	});
		    }
		    else if (v == 'cancel') {
		    }
		    return true; //close
		};
		getTopWin(window).jBox.confirm("确定要删除数据吗？", "提示", submit);
	}
	function changeStatus(id){
		$.ajax({
    		type : "POST",
    		url : "${pageContext.request.contextPath}/event/event-correlation!changeStatus.action", //请求的action
    		data : {id:id}, //传的参数
    		dataType : 'json',
    		success : function(data) { //结果
    			if(data == true){
    				window.setTimeout(function () { $.jBox.tip('成功', 'success'); }, 100);
    				datagrid();
    			}else{
    				getTopWin(window).getMessageBox().alert("此规则已经被删除了","提示");
    				datagrid();
    			}
    		}
    	});
	}
	function update(id){
		$.ajax({
    		type : "POST",
    		url : "${pageContext.request.contextPath}/event/event-correlation!checkDeleted.action", //请求的action
    		data : {id:id}, //传的参数
    		dataType : 'json',
    		success : function(data) { //结果
    			if(data.flag == true){
    				window.location.href="${pageContext.request.contextPath}/event/event-correlation!input.action?id="+id;
    			}else{
    				getTopWin(window).getMessageBox().alert("此规则已经被删除了","提示");
    				datagrid();
    			}
    		}
    	});
	}
	function view(id){
		$.ajax({
    		type : "POST",
    		url : "${pageContext.request.contextPath}/event/event-correlation!checkDeleted.action", //请求的action
    		data : {id:id}, //传的参数
    		dataType : 'json',
    		success : function(data) { //结果
    			if(data.flag == true){
    				window.location.href="${pageContext.request.contextPath}/event/event-correlation!view.action?id="+id;
    			}else{
    				getTopWin(window).getMessageBox().alert("此规则已经被删除了","提示");
    				datagrid();
    			}
    		}
    	});
	}
	function addStyle(){
		$("#nameSpan").css({"display":"none"});
		var oInput = document.getElementById("name");
		oInput.focus();
	}
	function delStyle(){
		if($("#name").val() == ''){
			$("#nameSpan").css({"display":""});
		}
	}
	</script>
  </head>
  
  <body>
  	<h2 class="title-h2"><span><img src="${pageContext.request.contextPath}/style/default/bsm/images/arrow-down.gif"/></span>事件相关性列表</h2>
    <%boolean sysManager = UserFunctionValidate.sysFunctionValidate(FunctionConstants.SYSTEM_MANAGER);%>
	 	<%if(sysManager){%>
  	<div class="toolbar" id = "toolbar">
 		<a class="page_add" href="javascript:add();">新增</a>
 		<div class="f-r-input" onclick="addStyle();"><input id="name" name="name" onfocus="addStyle();" onblur="delStyle();"><span id="nameSpan">搜索规则名称</span></div>
	</div>
	<%}%>
    <div>
		<table id="depmtList" width="100%" cellpadding="0" cellspacing="0" border="0" class="display">
			<thead>
				<tr>
	 			<%if(UserFunctionValidate.sysFunctionValidate(FunctionConstants.SYSTEM_MANAGER)){%>
					<th width="60px">操作</th>
				<%}%>		
					<th width="210px">规则名称</th>
					<th width="210px">主事件类别</th>
					<th width="60px">启用状态</th>
					<th>规则说明</th>
				</tr>
			</thead>
		</table>
	</div>
  </body>
</html>
